﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace Project_Vital.Dao
{
    public class SupplierDao
    {

        const string connectionString = "Server=NEXTGEN-TECH01;Database=Vital;Trusted_Connection=True";

        public void CreateSupplier(Supplier supplier)
        {
            vsup_vital_supplier newSupplier = this.TranformSupplier(supplier);
            ProjectVitalDataContext dataContext = new ProjectVitalDataContext(connectionString);
            dataContext.vsup_vital_suppliers.InsertOnSubmit(newSupplier);
            dataContext.SubmitChanges();
        }

        private vsup_vital_supplier TranformSupplier(Supplier supplier)
        {
            vsup_vital_supplier dbSupplier = new vsup_vital_supplier();

            dbSupplier.vsup_supplier_name = supplier._vsup_supplier_name;

            dbSupplier.vsup_supplier_addr1 = supplier._vsup_supplier_addr1;

            dbSupplier.vsup_supplier_addr2 = supplier._vsup_supplier_addr2;

            dbSupplier.vsup_supplier_city = supplier._vsup_supplier_city;

            dbSupplier.vsup_supplier_county = supplier._vsup_supplier_county;

            dbSupplier.vsup_supplier_country = supplier._vsup_supplier_country;

            dbSupplier.vsup_supplier_contact1 = supplier._vsup_supplier_contact1;

            dbSupplier.vsup_supplier_contact2 = supplier._vsup_supplier_contact2;

            dbSupplier.vsup_supplier_phone1 = supplier._vsup_supplier_phone1;

            dbSupplier.vsup_supplier_phone2 = supplier._vsup_supplier_phone2;

            dbSupplier.vsup_supplier_mobile = supplier._vsup_supplier_mobile;

            dbSupplier.vsup_supplier_fax = supplier._vsup_supplier_fax;

            dbSupplier.vsup_supplier_email = supplier._vsup_supplier_email;

            dbSupplier.vsup_opening_time = supplier._vsup_opening_time;

            dbSupplier.vsup_closing_time = supplier._vsup_closing_time;

           
            return dbSupplier;
        }
    }
}
